package com.gugee.tiktok.common.model.mysql;

import com.gugee.tiktok.common.model.spider.comment.Comment;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

@Data
public class AwemeComment {
    private long cid;
    private String text;
    private long createTime;
    private int diggCount;
    private long uid;
    private String uniqueId;
    private String cover;
    private String avatarMedium;
    /**
     * 语言
     */
    private String language;
    /**
     * 地区
     */
    private String region;
    private int replyCommentTotal=0;
    @Mapper(componentModel = "spring")
    public interface AwemeCommentMapper {
        @Mapping(target = "createTime", source = "create_time")
        @Mapping(target = "diggCount", source = "digg_count")
        @Mapping(target = "uid", source = "user.uid")
        @Mapping(target = "uniqueId", source = "user.unique_id")
        @Mapping(target = "replyCommentTotal", source = "replyCommentTotal")
        @Mapping(target = "cover", expression = "java(dto.getUser().getCover_url().get(0).getUrl_list().get(0))")
        @Mapping(target = "avatarMedium", expression = "java(dto.getUser().getAvatar_medium().getUrl_list().get(0))")
        @Mapping(target = "language", expression = "java(dto.getUser().getLanguage())")
        @Mapping(target = "region", expression = "java(dto.getUser().getRegion())")
        AwemeComment mapper(Comment dto);

        List<AwemeComment> mapper(List<Comment> dto);
    }
}
